import { expect } from 'chai';
import dexss from '../src/dexss.js';

describe('dexss', function() {
    it('should return empty string if empty arguments', function() {
        expect(dexss()).to.be.eql('');
    });

    it('should delete onerror handler', function() {
        const raw = '<img src=1 onerror=prompt(1)>';
        expect(dexss(raw)).to.be.eql('<img src=1>');
    });

    it('should delete onerror handler', function() {
        const raw = '<img onerror=prompt(1) src=1>';
        expect(dexss(raw)).to.be.eql('<img src=1>');
    });

    it('should delete onerror handler', function() {
        const raw = '<img src=1 onload="prompt(2)" onerror=prompt(1)>';
        expect(dexss(raw)).to.be.eql('<img src=1>');
    });

    it('should delete onerror handler', function() {
        const raw = '<img onerror=prompt(1) src=1 onload=prompt(2)>';
        expect(dexss(raw)).to.be.eql('<img src=1>');
    });

    it('should delete onerror handler', function() {
        const raw = '<img id="2" onerror=prompt(1) src=1 onload=prompt(2)>';
        expect(dexss(raw)).to.be.eql('<img src=1>');
    });
});
